feat: Trakt.tv integration — watched history overlay & hide-watched filter (#70)#71
Merged
feat: Trakt.tv integration — watched history overlay & hide-watched filter (#70)#71
Conversation
…ay (#70) - Backend: new router `app/routers/trakt.py` with 5 endpoints - POST /api/trakt/device/code — start device-code flow - POST /api/trakt/device/poll — poll for token, saves on success - POST /api/trakt/disconnect — revoke and clear stored tokens - GET /api/trakt/watched — TMDB IDs of watched movies (1h cache) - GET /api/trakt/status — connection state for config UI - Auto-refreshes access token on 401 via stored refresh token - Config UI: Trakt section with device-code connect flow - Shows live user code + countdown during authorisation - Switches to "Connected as @username + Disconnect" on success - TRAKT_HIDE_WATCHED toggle to filter watched movies from all grids - Cards: watched badge and dim overlay (👁 Watched) on watched movies - Filters: applyFilters() respects TRAKT_HIDE_WATCHED; wishlist tab exempt - 26 unit tests + E2E tests covering connect flow, badge, hide-watched Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1. Save config wiped OAuth tokens — saveConfig() now preserves TRAKT_ACCESS_TOKEN / REFRESH_TOKEN / USERNAME / ENABLED from in-memory CONFIG; falls back to CONFIG values when connect form fields are hidden (connected state) 2. Watched badges missing after browser refresh — _fetchTraktWatched() now triggers a render() on completion so the initial tab reflects the watched overlay without requiring a sidebar navigation 3. Hide-watched had no effect on Franchises / Directors / Actors — the grouped renderer bypasses applyFilters(); added the same _traktWatchedIds guard inline after genre/rating filters Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Backend: POST /api/trakt/watched/refresh — zeros the 1-hour cache timestamp so the next GET re-fetches live from Trakt - Config UI: "⟳ Refresh history" button next to Disconnect in the connected state (both initial render and after device-code connect) - Shows "✓ N watched movies" confirmation for 4s after refresh - Re-renders the current tab so badges/hide-watched update immediately Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The previous disconnect path called save_config(full_config) which goes through the _deep_merge pipeline. Replacing it with a direct YAML read→patch→write guarantees the four token fields are wiped in the file regardless of in-memory config state. - Backend: trakt_disconnect reads raw YAML, patches TRAKT section, writes back — bypasses save_config merge entirely - Backend: also clears _watched_cache data (not just ts) on disconnect - Frontend: traktDisconnect() now clears TRAKT_REFRESH_TOKEN from in-memory CONFIG too (was previously missed) - Test: updated to use tmp_path and verify the YAML file is actually patched on disk, not just that save_config was called Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
trakt.tv/activate, enters the displayed code, and CinePlete polls until authorised. Tokens + username saved automatically; access token auto-refreshes on expiry.👁 Watchedbadge appears on movie cards in the recommendation grids for any film in your Trakt watch history. Watched cards are dimmed (55% opacity, full on hover).TRAKT_HIDE_WATCHEDtoggle in config hides watched movies from all grids except Wishlist (where the filter is intentionally skipped).New endpoints
POST/api/trakt/device/codePOST/api/trakt/device/pollPOST/api/trakt/disconnectGET/api/trakt/watchedGET/api/trakt/statusTest plan
pytest tests/test_trakt.py— all 26 tests passnpx playwright test e2e/tests/trakt.spec.js) — config UI and card overlay tests pass✓ Connected as @usernameappears👁 WatchedbadgeTRAKT_HIDE_WATCHEDin config, save — confirm watched movies disappear from grids🤖 Generated with Claude Code